+2006-02-22 Øyvind Kolås <pippin@gimp.org>
+
+ * extensions/gggl.c: (conv_rgbaF_rgb8), (conv_rgbAF_rgbF), (init):
+ added two more conversions for gggl usage.
+
2005-12-17 Michael Schumacher <schumaml@cvs.gnome.org>
* extensions/Makefile.in: add libgw32 and its dependencies to
* gamma correction (not really,. gamma correction belongs in seperate ops,.
*/
-//#define USE_TABLES
+#define USE_TABLES
#ifdef USE_TABLES
/* lookup tables used in conversion */
return samples;
}
+static INLINE long
+conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+{
+ long n=samples;
+ while (n--)
+ {
+ register float f = (*(float *) src);
+ *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+ src += 4;
+ dst += 1;
+
+ f = (*(float *) src);
+ *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+ src += 4;
+ dst += 1;
+
+ f = (*(float *) src);
+ *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+ src += 4;
+ dst += 1;
+
+ src += 4;
+
+ }
+ return samples;
+}
+
+
/*********/
static INLINE long
conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
return samples;
}
+
+static INLINE long
+conv_rgbAF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+{
+ long n=samples;
+ while (n--)
+ {
+ float alpha = (((float *) src)[3]);
+ if (alpha >= 1.0)
+ {
+ register int c;
+ for (c = 0; c < 3; c++)
+ {
+ *(float *) dst = *(float *) src;
+ dst += 4;
+ src += 4;
+ }
+ }
+ else if (alpha <= 0.0)
+ {
+ register int c;
+ for (c = 0; c < 3; c++)
+ {
+ *(float *) dst = 0;
+ dst += 4;
+ src += 4;
+ }
+ }
+ else
+ {
+ register int c;
+ for (c = 0; c < 3; c++)
+ {
+ *(float *) dst = ((*(float *) src) / alpha);
+ dst += 4;
+ src += 4;
+ }
+ }
+ src += 4;
+ }
+ return samples;
+}
+
static INLINE long
conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
{
o (rgbaF, yuvaF);
o (rgbaF, rgbaD);
o (rgbaD, rgbaF);
+ o (rgbaF, rgb8);
+ o (rgbAF, rgbF);
#if 0
o (rgbF, xyzF);
o (xyzF, rgbF);